// Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
//
// Licensed under the Mulan PSL v2.
// You can use this file according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of the License at
//
//     http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
// FOR MORE DETAILS.

/*
 * @Author: qiulin_JXGM ql1746365080@gmail.com
 * @Date: 2024-09-19 15:38:51
 * @LastEditors: wxc superjava@qq.com
 * @LastEditTime: 2024-09-29 16:52:40
 * @FilePath: /SGFEM/DBManager/src/Service/Input/Dynamic/EIGCService.cpp
 */
#include "DBManager/Service/Input/Dynamic/EIGCService.h"

#include <cassert>

#include "Utility/Logging/SGLogger.h"

#include "DBManager/Common/ServiceMacro.h"
#include "DBManager/IRepository/Input/Dynamic/IEIGCRepository.h"
#include "DBManager/Service/Input/Dynamic/DynamicSummaryService.h"
using namespace SG::DBManager;

SERVICE_REG_IMPL1 (EIGCService, IEIGCRepository)

SERVICE_REG_SET_ISONE_SUMMARY (EIGCService, DynamicSummaryService)

EIGCService::EIGCService (IEIGCRepository& repos) : m_repository (repos)
{}

EIGCService::~EIGCService () = default;

SG::DataStructure::Common::Status EIGCService::FindBySId (SG::DataStructure::Common::Id sId, _OUT SG::DataStructure::FEM::EIGCData& entity)
{
    std::vector<SG::DataStructure::FEM::EIGCData> data;
    if (SG::DataStructure::Common::Status::STATUS_Success == m_repository.FindBySId (sId, data))
    {
        if (data.size () > 1)
        {
            SGWarn << "EIGC Service: FindBySId() return more than one data.";
        }
        entity = data[0];
        return SG::DataStructure::Common::Status::STATUS_Success;
    }
    return SG::DataStructure::Common::Status::STATUS_Failure;
}
